package com.device;


public class RFcard {
	
	public static int icdev = -1;		

	
	public static byte KEY_A=0;
	public static byte KEY_B=4;
	public static byte _SecNo=0,BlockNo=0;

	public static byte[] PIN = new byte[8];


	//-----------------------------------------------------------------------------------------------
	//�豸��������
	//-----------------------------------------------------------------------------------------------
	public static native int   rf_get_status(int icdev,byte[]  _Status);
	public static native int   rf_lib_ver(byte[] buff);
	public static native int   rf_beep(int  icdev,int ms);
	//-----------------------------------------------------------------------------------------------
	//ͨ�ú���
	//-----------------------------------------------------------------------------------------------
	public static native int  rf_init(int  icdev,long baud);
	public static native int  rf_exit(int icdev);
	public static native int  rf_card(int  icdev,byte _Mode,long[] _Snr);
	public static native int  rf_config(int  icdev,byte _Mode,byte _Baud);
	public static native int  rf_request(int  icdev,byte _Mode,byte[] TagType);
	public static native int  rf_anticoll(int  icdev,byte _Bcnt,byte[] _Snr);
	public static native int  rf_select(int  icdev,byte[] _Snr,byte[] _Size);
	public static native int  rf_load_key(int  icdev,byte _Mode,byte _SecNr,byte[] _Nkey);
	public static native int  rf_load_key_hex(int  icdev,byte _Mode,byte _SecNr,byte[] _NKey);
	public static native int  rf_halt(int  icdev);
	public static native int  rf_read(int  icdev,byte _Adr,byte[] _Data);
	public static native int  rf_read_hex(int  icdev,byte _Adr,byte[] _Data);
	public static native int  rf_write(int  icdev,byte _Adr,byte[] _Data);
	public static native int  rf_write_hex(int  icdev,byte _Adr,byte[] _Data);


	public static native int rf_HL_authentication(int icdev, byte reqmode, long snr, byte authmode, byte secnr);
	//-----------------------------------------------------------------------------------------------
	//M1��ר�ú���
	//-----------------------------------------------------------------------------------------------

	public static native int   rf_authentication(int  icdev,byte _Mode,byte _SecNr);
	public static native int   rf_changeb3(int  icdev,byte _SecNr,byte[] _KeyA,byte _B0,byte _B1,byte _B2,byte _B3, byte _Bk,byte[] _KeyB);
	public static native int   rf_initval(int icdev,byte _Adr,long _Value);
	public static native int   rf_increment(int icdev,byte _Adr,long _Value);
	public static native int   rf_decrement(int icdev,byte _Adr,long _Value);
	public static native int   rf_readval(int icdev,byte _Adr,long[] _Value);
	public static native int   rf_restore(int icdev,byte _Adr);
	public static native int   rf_transfer(int icdev,byte _Adr);
	              
	//-----------------------------------------------------------------------------------------------
	//M1���߼�����
	//-----------------------------------------------------------------------------------------------


	public static native int	rf_readM(int  icdev,byte _Adr,byte _Nm,byte[] _Data);  
	public static native int	rf_writeM(int  icdev,byte _Adr,byte _Nm,byte[] _Data);             

	//-----------------------------------------------------------------------------------------------
	//14443 ��׼�ӿ�		
	//-----------------------------------------------------------------------------------------------
	public static native int    rf_ISO14443A_request(int icdev,byte rmode,byte[] atq);
	public static native int    rf_ISO14443A_anticoll(int icdev,byte cmd,byte[] snr);
	public static native int    rf_ISO14443A_select(int icdev,byte cmd,byte[] snr);
	public static native int    rf_ISO14443A_findcard(int icdev,byte wmode,byte[] len,byte[] serial_nm);
	public static native int    rf_ISO14443A_ATS(int icdev,byte[] len,byte[] rats);
	public static native int 		rf_ISO14443A_APDU(int icdev,byte slen,byte[] sbuf,byte[] rlen, byte[] rbuf);
	public static native int  	rf_ISO14443A_Deselect(int icdev);
	public static native int    rf_ISO14443A_sendpkt(int icdev,byte crc_enable,byte slen,byte []sbuf,byte []rlen,byte []rbuf,int timeout);
	 //-----------------------------------------------------------------------------------------------
	//Ultralight CARD
	//-----------------------------------------------------------------------------------------------
	public static native int  	rf_UL_findcard(int icdev,byte wmode,byte[] len,byte[] serial_nm);
	public static native int  	rf_UL_read(int  icdev,byte _Adr,byte[] _Data);
	public static native int  	rf_UL_write(int  icdev,byte _Adr,byte[] _Data);

	public static native int  	rf_UL_readM(int  icdev,byte _Adr,byte _Nm,byte[] _Data);
	public static native int  	rf_UL_writeM(int  icdev,byte _Adr,byte _Nm,byte[] _Data);

	public static native int  	rf_rfinf_reset(int icdev,byte rflag);
	public static native int 	des_code(byte k,byte[] pdata,byte[]  dkey,byte[] res);
	public static native int 	des3_code(byte k,byte[] pdata,byte[]  dkey,byte[] res);


	//-----------------------------------------------------------------------------------------------
	//cpu��
	//-----------------------------------------------------------------------------------------------

	public static native long cpu_reset(int icdev,long [] rlen,byte [] buf);
	public static native long cpu_power_off(int icdev);
	public static native long cpu_access(int icdev,byte slen,byte [] send,byte[] rlen,byte[] receive);
	public static native long cpu_selsocket(int icdev,byte  samso);
	public static native long cpu_getsocket(int icdev,byte [] samso );
	public static native long cpu_reset2(int icdev,byte baud,byte ucVoltage ,long [] rlen,byte [] buf);         
	//-----------------------------------------------------------------------------------------------
	//ISO15693 CARD
	//-----------------------------------------------------------------------------------------------
	public static native int rf_ISO15693_Inventory_mult(int icdev, byte cmd, byte flags, byte AFI, byte cmfg, byte inv_mult_fnb, byte inv_mult_nbl, int times);
	public static native int rf_ISO15693_inventory_multreadtag(int icdev,  byte[] Rflags, byte[] DSFID, byte[] UID,byte[] ant_no,byte[] datalen,byte[] databuffer,int time_out );
	public static native int rf_ISO15693_stop_inventory(int icdev);
	public static native int rf_ISO15693_Inventory(int icdev, byte flags, byte AFI, byte masklengh, byte[] maskvalue, byte[] Rflags, byte[] DSFID, byte[] databuffer);
    public static native int rf_ISO15693_Stay_Quiet(int icdev,byte flags,byte[] UID);
    public static native int rf_ISO15693_Read(int icdev,byte flags,byte Firstblock, byte Number,byte[] UID,byte[] databuffer);
    public static native int rf_ISO15693_Write(int icdev,byte flags,byte Firstblock,byte Number,byte[] UID,byte[] databuffer);
    public static native int rf_ISO15693_Lock_Block(int icdev,byte flags,byte block,byte[] UID);
    public static native int rf_ISO15693_Select(int icdev,byte flags,byte[] UID);
    public static native int rf_ISO15693_Reset_To_Ready(int icdev,byte flags,byte[] UID);
    public static native int rf_ISO15693_Write_AFI(int icdev,byte flags, byte AFI, byte[] UID);
    public static native int rf_ISO15693_Lock_AFI(int icdev,byte flags,byte[] UID);
    public static native int rf_ISO15693_Write_DSFID(int icdev,byte flags,byte DSFID,byte[] UID);
    public static native int rf_ISO15693_Lock_DSFID(int icdev,byte flags,byte[] UID);
    public static native int rf_ISO15693_GET_System_Information(int icdev,byte flags,byte[] UID,byte[] databuffer);
    public static native int rf_ISO15693_GetMultipleBlockSecurity(int icdev,byte flags,byte Firstblock,byte Number,byte[] UID,byte[] databuffer);
	public static native int rf_ISO15693_Genericpkt(int icdev, byte txlen, byte[] txbuffer, byte[] rxlen, byte[] rxbuffer,int times);




}
